const { app, ipcMain } = require('electron')
const mainWindow = require('electron-main-window').getMainWindow()
const AppMainWindow = require('../controls/AppMainWindow')
//定义菜单
module.exports = [
  {
    label: '项目管理',
    submenu: [
      {
        label: '创建项目',
        click: function(item, focusedWindow) {
          if (app.mainWin !== null) {
            app.mainWin.webContents.send('router', '/HandleProject')
          }
        }
      },
      {
        label: '打开新项目',
        click: function(item, focusedWindow) {
          let win = new AppMainWindow();
          win.on('close', () => {
            win = null;
          })
          ipcMain.on('stop-loading-main', () => {
            win.removeView()
          })
        }
      },
      {
        label: '关闭窗口',
        accelerator: 'CmdOrCtrl+W',
        role: 'close'
      }
    ]
  },
  {
    label: '编辑',
    submenu: [
      {
        label: '复制',
        role: 'copy'
      },
      {
        label: '粘贴',
        role: 'paste'
      },
      {
        label: '截切',
        role: 'cut'
      },
      {
        label: '撤销',
        role: 'undo'
      }
    ]
  },
  {
    label: '窗口',
    submenu: [
      {
        label: '窗口最小化',
        role: 'minimize'
      },
      {
        label: '关闭当前窗口',
        role: 'close'
      },
      {
        label: '刷新',
        role: 'reload',
        accelerator: 'F5'
      },
      {
        label: '强制刷新',
        role: 'forceReload',
        accelerator: 'CmdOrCtrl+F5'
      },
      {
        label: '打开调试',
        role: 'toggleDevTools',
        accelerator: 'F12'
      },
      {
        label: '全屏切换',
        role: 'togglefullscreen',
        accelerator: 'CmdOrCtrl+q'
      }
    ]
  }
]

